Julia Quick Start

Download Julia here: https://julialang.org/downloads/

Open the Julia application. You should see a startup banner similar to this:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version x.y.z (YYYY-MM-DD)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia>

Try typing in 2+2 and hitting enter. If you know LaTeX, Julia is happy to think about LaTeX commands, so try typing in whcih turns into π and hitting enter

Install Visual Studio Code (VS Code)

After confirming Julia runs, download and install VS Code: https://code.visualstudio.com/

  • Open VS Code.
  • Click on the Extensions icon in the Activity Bar on the side of the window. It looks like four squares forming a larger square, with the top-right square slightly detached.
  • Search for “Julia” in the search bar.
  • Find the extension named Julia published by julialang and click Install.

Create and Run Your First Julia File

  • Create a new file named HelloJulia.jl.
  • Open this file in VS Code.
  • Paste the following code into the file:
println("The first digits of pi are: ", pi)
  • Run the code by clicking the Run button (a trinagluar play icon) in the top-right corner of the editor.

Manage Julia Packages

In the VS Code terminal panel where you saw the output, you should see the Julia prompt julia>. Press the ] key (right square bracket). The prompt will change to indicate you are in package mode. To exit Pkg mode and return to the standard julia> prompt, press the Backspace key.

While in Pkg mode, type the following command and press Enter:

add GLMakie CairoMakie DataFrames

Then wait for installation, this can take awhile.

Differentiate and graph data

Now you can modify your HelloJulia.jl script (or create a new one) to use these packages. Here’s an example that calculates the derivative of some data (a sine wave), then creates a simple plot using Makie and saves it as a PDF:

using GLMakie, CairoMakie

x = 0:0.1:2pi #create an x-range
y = sin.(x) #create some y-data, a sin wave.
∂y∂x = diff(y) ./ diff(x) #Calculate the derivative, cos!

# Create the plot figure and axis
fig = Figure(size = (400, 400))
ax = Axis(fig[1, 1], xlabel = "X [um]", ylabel = "Y [Pa]")

# Plot the lines
lines!(ax, x, y, label = "y=sin(x)", color = :blue, linewidth = 2)
lines!(ax, x[1:end-1], ∂y∂x, label = "∂y/∂x", color = :red, linewidth = 2)

axislegend(ax) # Add a legend

# Show the plot in an interactive window
GLMakie.activate!() 
fig #or display(fig)

# Save the plot as a PDF
#CairoMakie.activate!()
#save("plot.pdf", fig)

Some resources

MIT has a Julia Course, with a terrific YouTube series that teaches both Julia and some great foundations of programming for image analysis.

Julia has a dedicated YouTube Channel where you can see what people in the community are up to at various Julia conferences.